Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up seed generation from 494 ns/op to 3 ns/op #191

Merged
merged 1 commit into from
Oct 26, 2021

Conversation

fxamacker
Copy link
Member

Closes #190

Description

Use circlehash.Hash64Uint64x2() which accepts two uint64 values to hash. This avoids the need to create a new 16-byte slice and concatenation.

This code block is eliminated:

sIDBytes := make([]byte, storageIDSize)
_, err = sID.ToRawBytes(sIDBytes)
require.NoError(b, err)

Benchmark comparison on Haswell CPU with Go 1.16.9:

name             old time/op    new time/op    delta
HashSeedBytes-4     494ns ± 1%       3ns ± 0%  -99.45%  (p=0.000 n=20+19)

Hash64Uint64x2() is compatible with Hash64() for 16-byte inputs (given same inputs, they produce identical digests).


  • Targeted PR against main branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@fxamacker fxamacker merged commit 734a61c into main Oct 26, 2021
@fxamacker fxamacker deleted the fxamacker/optimize-seed branch November 5, 2021 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Speed up seed generation from 494 ns/op to 3 ns/op
2 participants